package com.md.mapper;

import com.md.entity.Blog;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BlogMapper {
    @Select("select * from blog")
    List<Blog> selectAll();

    @Select("select * from blog where blogId=#{id}")
    Blog selectById(int id);

    @Select("select * from blog where blogTitle like '%${blogTitle}%'")
    List<Blog> selectName(String name);

    @Delete("delete from blog where blogId=#{id}")
    int deleteById(int id);

    @Insert("insert into blog(blogTitle, blogAuthor, blogText) values (#{blogTitle},#{blogAuthor},#{blogText})")
    int insertById(Blog blog);

    @Update("update blog set blogTitle=#{blogTitle}, blogAuthor=#{blogAuthor}, blogText=#{blogText} where blogId=#{blogId}")
    int updateById(Blog blog);
}
